#ifndef __THREAD_H__
#define __THREAD_H__

#include "common_Mutex.h"
#include <unistd.h>


class Thread {
public:
	Thread() : r(true) {}
	virtual void start() {
		pthread_create(&t, 0, callback, this);
	}
	virtual void stop() {
		r = false;
	}
	virtual void join() {
		void *p;
		pthread_join(t, &p);
	};
	virtual void run() = 0;
	virtual ~Thread() {};
	virtual bool isRunning() {
		if(r)
			return true;
		return false;
	}
private:
	bool r;
	pthread_t t;
	static void* callback(void* o) {
		((Thread*)o)->run();
		return NULL;
	}
	Thread(const Thread &c) {}
};

#endif
